Configure Calculated Attribute: Settings
The Settings tab allows you to configure high-level properties for a Calculated Attribute, such as refresh behavior, caching rules, and conditions for population.
To configure the settings of the Calculated Attribute:
-
Navigate to the Settings tab of the Member Attribute Details screen.
-
Check Read-only. This setting is required for Calculated Attributes.
-
Within the Calculated Attribute Settings section, optionally check one or both of the following refresh triggers: Activity is Processed and API Requests Calculation. These options both refer to the On-demand computation mode, and specify what events can cause the platform to refresh the Calculated Attribute.
Note: Calculated Attributes can always be refreshed by a Scheduled Job in addition to one or both of the above options.
-
In the TTL (Time-to-Live) field, enter the number of seconds that the calculated value remains valid before being re-calculated (applicable to API requests only).
When a Calculated Attribute is accessed by an API request, the platform checks whether its value is still within the defined TTL range. If the value is within the TTL range, the platform uses the existing cached value. If the value is beyond the TTL range, the platform recalculates it.
When determining the TTL value for your Calculated Attribute, consider the type of data stored in this field, and how it will be used. If you make the TTL value too short, you potentially impact performance by unnecessarily recalculating a value when you may not need to. Conversely, if you make the TTL value too long, you risk using outdated or "stale" data. Generally speaking, you must determine a TTL value that strikes a balance between performance and timeliness.
The Condition section allows you to optionally apply a logical condition that identifies which records need to have this Calculated Attribute populated. To define a condition:
-
Click the Add icon, then select Add Rule. The platform adds a new blank row.
-
The first drop-down menu is populated with all of the different object types in Loyalty that are available for use. From this drop-down menu, select one of the following object types to expand it and see the available options:
This option allows you to define a logical statement based on a value in a Member Attribute.
-
From the menu, select the desired Member Attribute.
-
Select a mathematical operator; the available operators will vary based on the Data Type of the item you selected above.
-
Enter or select a value.
This option allows you to define a logical statement based on a value in a Member Preference.
-
From the menu, select the desired Member Preference.
-
Select a mathematical operator.
-
Enter or select a value.
This option allows you to define a logical statement by performing a mathematical calculation on a selected Activity Type.
-
From the menu, select the desired calculation method: Aggregate, Count, or Recency.
-
From the second drop-down menu, select the desired Activity Type.
-
Select a mathematical operator.
-
Enter or select a value.
-
Based on the selected calculation method, the platform provides the option to enter additional criteria:
-
Count: Define a time period, such as "Is In Last 3 Months." The use of a time period is optional, but recommended to improve system performance.
-
Aggregate: Select how to perform the aggregation: either by picking an Attribute on which to aggregate, or by entering a Groovy expression. Select the Aggregate Function: Sum, Minimum, or Maximum. Define a time period, such as "Is In Last 3 Months." The use of a time period is optional, but recommended to improve system performance.
-
This option allows you to define a logical statement using a Member's history of Metric usage.
-
From the menu, select the desired usage type: Balance, Earn, Expire, or Redeem.
-
From the second drop-down menu, select the desired Metric.
-
Select a mathematical operator.
-
Enter or select a value.
-
For the Earn, Expire, and Redeem Metric usage types, define a time period, such as "Is In Last 3 Months." The use of a time period is optional, but recommended to improve system performance.
This option allows you to define a logical statement by referencing either a Lookup table or a Member Function.
-
From the menu, select either Lookup or Function.
-
From the second drop-down menu, select the desired Lookup table or Member Function.
-
Select a mathematical operator.
-
Enter or select a value.
-
If you selected a Lookup table and it has Parameters defined, select the Attribute on which to match.
-
If you selected a Member Function and it has Arguments defined, select the Attribute on which to match.
This option allows you to define a logical statement using a Groovy expression.
-
From the menu, select Advanced Expression.
-
In the code editor field, enter the desired Groovy expression.
This option allows you to define a logical statement by referencing a Custom Object.
-
From the menu, select either the desired Custom Object.
-
Select a mathematical operator.
-
Enter or select a value.
-
Optionally, define a Condition that limits what records from the Custom Object are included.
-
Repeat the above steps as needed to define more Rules. Optionally, to remove a Rule, click the Remove icon next to it.
-
Once you define more than one Rule, select the logical operator from the Include customers that meet drop-down menu:
-
All of the following: Use an 'AND' operator such that all Rules must be true for a record to be selected.
-
Some of the following: Use an 'OR' operator such that at least one of the Rules must be true for a record to be selected.
-
-
Optionally, you can also organize Rules into Rule Groups. A Rule Group allows you to build more complex selection criteria. To create a Rule Group, click the Add icon, then select Add Rule Group. The platform creates a Group, which is represented visually as a nested box with its own operator and Add icon. Within this Group box, click the Add icon to define the Rule (or Rules) using the same process as described above. Use the toggle within the Group box to define the logical operator for the Rules within the Group.
Note: By clicking the Group button inside the Group box, you can create "nested" groups.
-
Click Save.